package com.cdvtc.flower.web.servlet;

import com.cdvtc.flower.dao.OrderDao;
import com.cdvtc.flower.dao.impl.OrderDaoImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/cancel-order")
public class CancelOrderServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;


    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String id = request.getParameter("id");
        if (id != null) {
            OrderDao orderDao = new OrderDaoImpl();
            orderDao.cancelOrder(Integer.parseInt(id));
        }
        response.sendRedirect("orders.jsp");
    }

}
